Pop Function

Removes the last element from an array and returns its value.

Syntax

result = array.Pop




Notes

The Append and Pop methods can be used together to treat an array as a stack.The Append method pushes a new element onto the array/stack and the Pop method removes the last element from the array/stack and returns its value.


Example

This is a directory-crawling routine that performs a depth-first traversal without using recursion:

Dim ItemsToInspect(0) As FolderItem
Dim item As FolderItem
Dim ctr As Integer
ItemsToInspect(0) = directory
While Ubound(itemsToInspect) >= 0
 item = itemsToInspect.Pop
 If item.Directory Then
  For ctr = 1 To item.Count
   itemsToInspect.Append item.Item(i)
  Next
 End If
Wend

See Also

Dim statement; Array, Join, Split, Ubound functions; Append, IndexOf, Insert, Redim, Remove, Shuffle, Sort, Sortwith methods; ParamArray keyword.